Skip to content

Add run_type tag to dagrun.duration.failed timeout metric - #67765

Merged
potiuk merged 1 commit into
apache:mainfrom
Vamsi-klu:fix/64765-dagrun-duration-failed-run-type-tag
Jul 30, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
Vamsi-klu:fix/64765-dagrun-duration-failed-run-type-tag

Conversation

@Vamsi-klu

@Vamsi-klu Vamsi-klu commented May 30, 2026 •

Copy link
Copy Markdown

What / impact

When a Dag run timed out, the scheduler emitted the dagrun.duration.failed timing metric with only a dag_id tag. Every other dagrun.duration.* emission also carries run_type, so dashboards and alerts that segment by run_type silently dropped timed-out runs (or saw an inconsistent tag set). After this change the timeout path emits both dag_id and run_type, consistent with normal completion.

Why

The timeout branch in _schedule_dag_run hardcoded tags={"dag_id": dag_run.dag_id}, while the canonical emitter DagRun._emit_duration_stats_for_finished_state uses dag_run.stats_tags (which includes run_type). This replaces the hardcoded dict with dag_run.stats_tags. run_type is NOT NULL and low-cardinality, so the new tag set is a safe strict superset of the old one and the metric name is unchanged.

How it unblocks

Makes timeout-duration metrics consistent and usable in run_type-segmented observability. Supersedes #64768, which stalled on CI/static checks rather than design — this keeps the diff to a single value change and ships green static checks, including the metrics-registry sync check that blocked the prior attempt.

Tests

One new regression test in test_scheduler_job.py, verified to fail on the unfixed code, asserting the dagrun.duration.failed timing call carries tags={"dag_id": …, "run_type": …}. Full scheduler suite passes; mypy + pre-commit + manual static checks (incl. metrics-registry sync) are green.

closes: #64765


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.8)

Generated-by: Claude Code (Opus 4.8) following the guidelines


Important

🛠️ Maintainer triage note for @Vamsi-klu · by @potiuk · 2026-07-02 17:46 UTC

Helpful heads-up from the maintainers — please address before this PR can be reviewed (see the Pull Request quality criteria):

  • This PR has merge conflicts with main. Please rebase onto the latest main and resolve them.

The ball is in your court — you've been assigned to this PR. Fix the above, then mark it Ready for review.

Automated triage — may be imperfect; a maintainer takes the next look.

@Vamsi-klu

This comment was marked as spam.

@potiuk potiuk added the ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green. label Jun 12, 2026
@potiuk
potiuk marked this pull request as draft July 2, 2026 17:47
When a Dag run timed out, the scheduler emitted dagrun.duration.failed with
only a dag_id tag, while every other dagrun.duration.* metric (emitted by
DagRun._emit_duration_stats_for_finished_state) also carries run_type. This
made the timeout path inconsistent and dropped run_type from dashboards and
alerts for timed-out runs.

Emit the metric with dag_run.stats_tags so it includes both dag_id and
run_type, matching the canonical completion path.

closes: apache#64765
@Vamsi-klu

This comment was marked as spam.

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct and nicely scoped — switching to dag_run.stats_tags makes the timeout path consistent with DagRun._emit_duration_stats_for_finished_state, and the test pins the tag set. The newsfragment is appropriate since the metric shape is user-visible.

One thing worth being aware of downstream: dashboards keyed on the old tag set will now see an extra dimension.


Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting

@potiuk
potiuk merged commit 3fb080b into apache:main Jul 30, 2026
77 of 78 checks passed
@potiuk potiuk added this to the Airflow 3.3.1 milestone Jul 30, 2026
potiuk added a commit that referenced this pull request Jul 30, 2026
…#67765) (#70731)

(cherry picked from commit 3fb080b)

Co-authored-by: deepinsight coder <32898216+Vamsi-klu@users.noreply.github.com>
vatsrahul1001 pushed a commit that referenced this pull request Aug 5, 2026
…#67765) (#70731)

(cherry picked from commit 3fb080b)

Co-authored-by: deepinsight coder <32898216+Vamsi-klu@users.noreply.github.com>
dabla pushed a commit to dabla/airflow that referenced this pull request Aug 14, 2026
imrichardwu pushed a commit to imrichardwu/airflow that referenced this pull request Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:scheduler ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dagrun.duration.failed metric missing run_type tag when failure caused by dagrun_timeout

2 participants